import Vue from 'vue'
import Vuex from 'vuex'
import App from './App.vue'
import vuetify from './plugins/vuetify'
import '@mdi/font/css/materialdesignicons.css'
import 'material-design-icons-iconfont/dist/material-design-icons.css'
import router from './router'
import store from './store'
import directive from './directive'

Vue.config.productionTip = false
Vue.use(Vuex)
Vue.use(directive)

const root = new Vue({
  router,
  store,
  vuetify,
  render: (h) => h(App)
}).$mount('#app')

Vue.prototype.$toast = root.$children[0].$refs.toast
Vue.prototype.$loading = root.$children[0].$refs.loading
Vue.prototype.$layer = root.$children[0].$refs.layer

Promise.prototype.complete = function (callback) {
  const p = this.constructor
  return this.then(
    (value) => p.resolve(callback()).then(() => value),
    (reson) =>
      p.resolve(callback()).then(() => {
        throw reson
      })
  )
}
